package com.qing.common.view

import android.annotation.SuppressLint
import android.content.Context
import android.view.WindowInsets
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.ViewCompat
import androidx.core.view.updatePadding

@SuppressLint("WrongConstant")
class TopToolStatusBarView : ConstraintLayout {

    private val TAG = "TopToolStatusBarView"

    constructor(context: Context) : this(context, null)

    constructor(context: Context, attrs: android.util.AttributeSet?) : this(context, attrs, 0)

    constructor(context: Context, attrs: android.util.AttributeSet?, defStyleAttr: Int) : this(
        context,
        attrs,
        defStyleAttr,
        0
    )

    constructor(
        context: Context,
        attrs: android.util.AttributeSet?,
        defStyleAttr: Int,
        defStyleRes: Int
    ) : super(context, attrs, defStyleAttr, defStyleRes)

    init {
        ViewCompat.setOnApplyWindowInsetsListener(this) { view, insets ->
            view.updatePadding(top = insets.getInsets(WindowInsets.Type.statusBars()).top)
            insets
        }
    }

}